package com.zhf.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zhf.dao.PromotionAdMapper;
import com.zhf.domain.PromotionAd;
import com.zhf.domain.PromotionAdVO;
import com.zhf.service.PromotionAdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @Author: ZhaoHuanfeng
 * @Date: 2020/12/4 21:14
 */
@Service
public class PromotionAdServiceImpl implements PromotionAdService {

    @Autowired
    private PromotionAdMapper propertyAdMapper;

    @Override
    public PageInfo<PromotionAd> findAllPromotionAdByPage(PromotionAdVO promotionAdVO) {
        Page<Object> objects = PageHelper.startPage(promotionAdVO.getCurrentPage(), promotionAdVO.getPageSize());
        List<PromotionAd> promotionAdList = propertyAdMapper.findAllPromotionAdByPage();

        PageInfo<PromotionAd> pageInfo=new PageInfo<PromotionAd>(promotionAdList);
        return pageInfo;
    }

    @Override
    public void updatePromotionAdStatus(int id, int status) {
        PromotionAd promotionAd = new PromotionAd();
        promotionAd.setId(id);
        promotionAd.setStatus(status);
        promotionAd.setUpdateTime(new Date());
        propertyAdMapper.updatePromotionAdStatus(promotionAd);
    }
}
